package Day5Zuoye;

import java.io.*;

public class Test4 {
    public static void main(String[] args) {
        BufferedReader br=null;
        try {
            FileInputStream fis=new FileInputStream("C:\\Users\\Administrator\\Desktop\\xinjian\\chaoxian.txt");
            br=new BufferedReader(new InputStreamReader(fis,"utf-8"));
            long time1=System.nanoTime();
            String str=null;
            int i=0;
            while ((str=br.readLine())!=null){
                System.out.println(str.length()+","+str);
                i++;
            }
            System.out.println("共"+i+"行");
            long time2=System.nanoTime();
            long time3=time2-time1;
            System.out.println("用时"+time3+"毫秒");
            long time4=System.nanoTime();
            byte [] list=new byte[1];
            int length=0;
            length=fis.read(list);
            System.out.println(new String(list,0,length));
            int count=0;
            if (list.toString()=="\n"){
                count++;
                System.out.println(count+"行");
            }
            long time5=System.nanoTime();
            long time6=time5-time4;
            System.out.println("用时"+time6+"毫秒");
            String b=time3>time6?"br.readLine快":"byte快";
            System.out.println(b);
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            try {
                br.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }


    }
}
